package db

import (
	"d-serv-go/server/core/bean"
	"github.com/bitly/go-simplejson"
)

var ServMgr ServInterface

type ServInterface interface {

	Act(paramBean *ParamBean) *bean.OutBean

	Act3(servId string, act string, paramBean *ParamBean) *bean.OutBean

	GetServJson(servId string) (*simplejson.Json, error)
}

var ServDao ServDaoInterface

type ServDaoInterface interface {

	Create(servId string, dataBean *ParamBean) (*bean.Bean, error)

	Update(servId string, dataBean *ParamBean) (*bean.Bean, error)

	Save(servId string, dataBean *ParamBean) (*bean.Bean, error)

	Updates(servId string, setBean *bean.Bean, whereBean *ParamBean) (int64, error)

	FindById(servId string, id string, withLinks bool) (*bean.Bean, error)

	Find1(servId string, paramBean *ParamBean) (*bean.Bean, error)

	Finds(servId string, paramBean *ParamBean) ([]*bean.Bean, error)

	FindsCall2(servId string, paramBean *ParamBean, call Callback) ([]*bean.Bean, error)

	Count(servId string, paramBean *SqlBean) (int, error)
}



var DictMgr DictInterface

type DictInterface interface {

	GetName(dictId string, code string) string

	GetItem(dictId string, code string) *bean.Bean

	GetItemMap(dict *bean.Bean) *bean.Bean

	GetCmpyItemMap(dict *bean.Bean, cmpy string) *bean.Bean

	GetItemCmpyBean(dict *bean.Bean,cmpy string) *bean.Bean

	GetDict(dictId string) *bean.Bean

	GetDictItemList(dict *bean.Bean, cmpyCode string) *bean.Bean

	Contains(dictId, code string) bool

	GetTreeList(dictId,  pid string, disLayer int, showPid bool) []*bean.Bean

	GetItemList(dict *bean.Bean, cmpy string) []*bean.Bean

	GetDynaItemList(s string, paramBean *ParamBean) *bean.OutBean

	HandleTree(tree []*bean.Bean, f ListHandler)

	IsSingleTree(dict *bean.Bean) bool

	GetFullNames(dictId string, codes string) string
}


var RoleMgr RoleInterface

type RoleInterface interface {

	GetRoleCodes(code string, code2 string, level int) []string

}

var MenuMgr MenuInterface

type MenuInterface interface {

	MenuToCache(userCode string) []*bean.Bean
	
}

var DataAclMgr DataAclInterface

type DataAclInterface interface {
	ReplaceDataAcl(where string) string
}

var AclMgr AclInterface

type AclInterface interface {

	GetDictAcls2( dictId,  userCode string) []string
}

type ListHandler func(data *bean.Bean)